
//获取应用实例
const app = getApp()
var commonData = require('../../data/data.js');
Page({
  data: {
    monsterList:[],
    isPowerShow:false,
    currentMonster:{}
  },
  showDetail:function(e){
    var _id = e.currentTarget.dataset.id;
    var instance = this.getInstanceById(_id, this.data.monsterList);
    this.setData({
      isPowerShow:true,
      currentMonster:instance
    });
  },
  hideDetail:function(){
    this.setData({
      isPowerShow: false,
      currentMonster: {}
    });
  },
  getInstanceById: function (id, list) {
    var res = null;
    for (var i = 0; i < list.length; i++) {
      if (id == list[i].id) {
        res = list[i];
        break;
      }
    }
    return res;
  },
  onLoad: function () {
    this.setData({
      monsterList: commonData.monsters
    });
    
  },
  onShow: function () {

  },

  

})
